import {getObject} from "../../utils/databaseUtil";

export async function getOrder(orderObjectId) {
    var query_orderItem = new AV.Query('orderItem');
    var order = AV.Object.createWithoutData('order', orderObjectId);
    query_orderItem.equalTo('order', order);

    // 想在查询的同时获取关联对象的属性则一定要使用 `include` 接口用来指定返回的 `key`
    query_orderItem.include('order');
    query_orderItem.include('fabric');
    query_orderItem.include('design');
    var a = await  query_orderItem.find().then(res => res.map(item => item.toJSON()))
    return a
}

export async function pay_order(orderId) {

    var todo = getObject("order")
    todo.id = orderId
    todo.set('status', '已付款');
    var result = await todo.save();
    return result.toJSON()
}